package com.zhi.service.impl;

import com.zhi.dao.LeaveInfoRepository;
import com.zhi.entity.ALeaveInfo;
import com.zhi.service.LeaveInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;

@Service
public class LeaveInfoServiceImpl implements LeaveInfoService {
	
	@Autowired
	private LeaveInfoRepository leaveInfoRepository;

	@Override
	public List<ALeaveInfo> getEntityList() {
		return leaveInfoRepository.findAll();
	}

	@Override
	public ALeaveInfo getOne(Integer id) {
		return leaveInfoRepository.getOne(id);
	}

	@Override
	public List<ALeaveInfo> findAll(ALeaveInfo aLeaveInfo){
		Example<ALeaveInfo> example =Example.of(aLeaveInfo);
		return leaveInfoRepository.findAll(example);
	}

	@Override
	public void save(ALeaveInfo leave) {
		leaveInfoRepository.save(leave);
	}

	@Override
	public void saveAll(List<ALeaveInfo> aLeaveInfos){
		leaveInfoRepository.saveAll(aLeaveInfos);
	}

	@Override
	public void edit(ALeaveInfo leave) {
		leaveInfoRepository.save(leave);
		
	}

	@Override
	public void delete(Integer id) {
		leaveInfoRepository.deleteById(id);
	}

	@Override
	public void deleteByLeaveId(Integer id){
		leaveInfoRepository.deleteByLeaveId(id);
	}

}
